package com.ccxe.manage.dao.impl;

import java.sql.ResultSet;

import com.ccxe.manage.dao.LoginDAO;
import com.ccxe.manage.db.CcxDB;
import com.ccxe.manage.db.CcxDBCommon;
import com.ccxe.manage.db.DBFactory;


public class AdminLoginDaoImpl extends CcxDBCommon implements LoginDAO {


	public AdminLoginDaoImpl() throws Exception {
		super();
	}
	
	public boolean getLogin(String user ,String pass) {
		int a = 0;
		CcxDB ccxDB=null; 
		ResultSet res=null;
		try {
			String sql = "select count(*) from c_operator t inner join c_operator_password a on a.operator_id = t.operator_id where t.operator_id=? and a.password=?";
			Object[] items=new Object[2];
			items[0] =user;
			items[1]=pass;
			ccxDB=DBFactory.getInstance();
			res = ccxDB.executeQuery(sql,items);
			if (res.next()) {
				 a = res.getInt(1);
				if(a>0)
				{
					return true;
				}
			}
			return false;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				this.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		return false;
	}

	@Override
	public long getNextAddressNumber() throws Exception {
		return 0;
	}

	@Override
	public long getNextMsgNumber() throws Exception {
		return 0;
	}

}